import { RobotGltf } from "../gltf/robot";
import { CapsuleMesh } from "../mesh/capsule";
import { OutsideMesh } from "../mesh/outside";
import { ThreeLight } from "../three/light";
import { ThreeScene } from "../three/scene";

export class RobotScene {
    private threeScene = new ThreeScene();
    private threeLight = new ThreeLight();
    private robotGltf = new RobotGltf();
    private capsuleMesh = new CapsuleMesh();
    private insideMesh = new OutsideMesh();
    private scene;

    constructor() {
        this.scene = this.threeScene.create();
    }

    init() {
        // const fillLight1 = this.threeLight.hemisphere(0x4488bb, 2.5);
        // fillLight1.position.set(2, 1, 1);
        // this.scene.add(fillLight1);

        const ambientLight = this.threeLight.ambient();
        this.scene.add(ambientLight);

        // const directionalLight = this.threeLight.directional(0xffffff, 0.8);
        // directionalLight.position.set(-5, 25, -1);
        // directionalLight.castShadow = true;
        // directionalLight.shadow.camera.near = 0.01;
        // directionalLight.shadow.camera.far = 500;
        // directionalLight.shadow.camera.right = 30;
        // directionalLight.shadow.camera.left = -30;
        // directionalLight.shadow.camera.top = 30;
        // directionalLight.shadow.camera.bottom = -30;
        // directionalLight.shadow.mapSize.width = 1024;
        // directionalLight.shadow.mapSize.height = 1024;
        // directionalLight.shadow.radius = 4;
        // directionalLight.shadow.bias = -0.00006;
        // this.scene.add(directionalLight);

        const capsule = this.capsuleMesh.create();

        this.scene.add(capsule);

        this.robotGltf.loader().then(glft => {
            this.scene.add(glft.scene);
           
        })
        return this.scene;
    }

    play() {
        this.robotGltf.fadeToAction('Walking');
    }

    animate() {
        this.robotGltf.animate();
    }
}